package company.shopee_F;

import java.util.*;

public class Shopee07 {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        String str = sc.nextLine();
        String[] numStr = str.split(",");
        TreeMap<String, Integer> treeMap = new TreeMap<>(new Comparator<String>() {
            @Override
            public int compare(String s1, String s2) {
                if (s1.length() == s2.length())
                    return s2.compareTo(s1);
                else {
                    StringBuffer sb = new StringBuffer();
                    int m, n;
                    if (s1.length() > s2.length()) {
                        n = s1.length() / s2.length();
                        m = s1.length() % s2.length();
                        for (int i = 0; i < n; i++) {
                            sb.append(s2);
                        }
                        String tmp = s2.substring(0, m);
                        sb.append(tmp);
                        return sb.toString().compareTo(s1) != 0 ? sb.toString().compareTo(s1) : 1;
                    } else {
                        n = s2.length() / s1.length();
                        m = s2.length() % s1.length();
                        for (int i = 0; i < n; i++) {
                            sb.append(s1);
                        }
                        String tmp = s1.substring(0, m);
                        sb.append(tmp);
                        return s2.compareTo(sb.toString()) != 0 ? s2.compareTo(sb.toString()) : 1;
                    }
                }
            }
        });
        for (String string : numStr) {
            treeMap.put(string, treeMap.getOrDefault(string, 0) + 1);
        }
        for (Map.Entry<String, Integer> entry : treeMap.entrySet()) {
            String tmp = entry.getKey();
            Integer n = entry.getValue();
            for (int i = 0; i < n; i++) {
                sb.append(tmp);
            }
        }
        System.out.println(sb.toString());
    }
}
